import { FormProps, FormSchema } from '/@/components/Table';
import { BasicColumn } from '/@/components/Table/src/types/table';
import {  h } from 'vue';
import { Tag } from 'ant-design-vue';

//表格显示列
export function getBasicColumns(): BasicColumn[] {
  // @ts-ignore
  return [
    {
      title: 'ID',
      dataIndex: 'classificationId',
      fixed: 'left',
      width: 100,
    },
    {
      title: '分类名称',
      dataIndex: 'classificationName',
      width: 150,

    },
    {
      title: '上级分类',
      dataIndex: 'pClassificationName',
      width: 100,
      customRender: ({ record }) => {
        const parentId = record.parentId;
        const text = parentId == '-1' ? '' : record.pclassificationName;
        return h(Tag, { color: 'green' }, () => text);
      },
    },
  ];
}

export function getFormConfig(): Partial<FormProps> {
  return {
    labelWidth: 150,
    baseColProps: { lg: 6, md: 24 },
    schemas: formParamSchema,
  };
}


//编辑表单
export const formParamSchema: FormSchema[] = [

];

//编辑表单
export const formSchema: FormSchema[] = [
  {
    field: 'classificationName',
    label: '分类名称',
    component: 'Input',
    required: true,
  },
  {
    field: 'parentId',
    label: '上级分类',
    component: 'TreeSelect',
    helpMessage: ['若没有分类,请到分类管理中添加'],
    componentProps: {
      fieldNames: {
        label: 'name',
        key: 'id',
        value: 'id',
      },
      getPopupContainer: () => document.body,
    },
  },

];
